package com.dhecp.project.flowable.controller;

import com.dhecp.common.core.controller.BaseController;
import com.dhecp.common.core.page.TableDataInfo;
import com.dhecp.core.constant.ModuleTable;
import com.dhecp.project.finance.domain.*;
import com.dhecp.project.finance.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @program: kjecp
 * @description: 特殊任务处理
 * @author: hlf
 * @create: 2023-06-12 10:22
 */
@Controller
@RequestMapping("/flowable/specialtask")
public class ActProcessSpecialTaskController extends BaseController {


    //运营服务费申请
    private String OPERATE_SERVICE_CHARGE_APPLY = ModuleTable.OPERATE_SERVICE_CHARGE_APPLY;
    //职能费用申请
    private String REIMBURSEMENT_APPLY = ModuleTable.REIMBURSEMENT_APPLY;
    //合作商付款申请
    private String PARTNER_PAYMENT_APPLY = ModuleTable.PARTNER_PAYMENT_APPLY;
    //入账申请
    private String PARTNER_BOOKED_APPLY = ModuleTable.PARTNER_BOOKED_APPLY;
    //公司费用划拨(运营-运营)
    private String OPERATE_EXPENSE_TRANSFER_YY = ModuleTable.OPERATE_EXPENSE_TRANSFER_YY;
    //公司费用划拨(职能-职能)
    private String OPERATE_EXPENSE_TRANSFER_CW = ModuleTable.OPERATE_EXPENSE_TRANSFER_CW;
    //公司费用划拨(运营-职能)
    private String OPERATE_EXPENSE_TRANSFER = ModuleTable.OPERATE_EXPENSE_TRANSFER;

    //运营服务费申请
    @Autowired
    private OperateServiceChargeApplyService operateServiceChargeApplyService;
    //职能费用申请
    @Autowired
    private ReimbursementApplyService reimbursementApplyService;
    //合作商付款申请
    @Autowired
    private PartnerPaymentApplyService partnerPaymentApplyService;
    //入账申请
    @Autowired
    private PartnerBookedApplyService partnerBookedApplyService;
    //公司费用划拨
    @Autowired
    private OperateExpenseTransferService operateExpenseTransferService;


    //根据modelTable和NID获取任务详细数据
    @RequestMapping("/getTaskData")
    @ResponseBody
    public TableDataInfo todoTaskList(@RequestParam Map<String, Object> params) {
        startPage();
        try {
            if (params.get("moduleTable").toString().toUpperCase().contains("TCW_OPERATESERVICECHARGEAPPLY")) {
                //运营服务费申请
                List<OperateServiceChargeApply> list = operateServiceChargeApplyService.queryList(params);
                return getDataTable(list);
            }else if (params.get("moduleTable").toString().toUpperCase().contains("TCW_REIMBURSEMENTAPPLY")){
                //职能费用申请
                List<ReimbursementApply> list = reimbursementApplyService.queryList(params);
                return getDataTable(list);
            }else if (params.get("moduleTable").toString().toUpperCase().contains("TCW_PARTNERPAYMENTAPPLY")){
                //合作商付款申请
                List<PartnerPaymentApply> list = partnerPaymentApplyService.queryList(params);
                return getDataTable(list);
            }else if (params.get("moduleTable").toString().toUpperCase().contains("TCW_PARTNERBOOKEDAPPLY")){
                //入账申请
                List<PartnerBookedApply> list = partnerBookedApplyService.queryList(params);
                return getDataTable(list);
            }else if (params.get("moduleTable").toString().toUpperCase().contains("TCW_OPERATEEXPENSETRANSFERYY")){
                //公司费用划拨(运营-运营)
                List<OperateExpenseTransfer> list = operateExpenseTransferService.queryList(params);
                return getDataTable(list);
            }else if (params.get("moduleTable").toString().toUpperCase().contains("TCW_OPERATEEXPENSETRANSFERCW")){
                //公司费用划拨(职能-职能)
                List<OperateExpenseTransfer> list = operateExpenseTransferService.queryList(params);
                return getDataTable(list);
            }else if (params.get("moduleTable").toString().toUpperCase().contains("TCW_OPERATEEXPENSETRANSFER")){
                //公司费用划拨(运营-职能)
                List<OperateExpenseTransfer> list = operateExpenseTransferService.queryList(params);
                return getDataTable(list);
            }else{
                return getDataTable(new ArrayList<>());
            }
        } catch (Exception e) {
            e.printStackTrace();
            return getDataTable(this.getExceptionMessage(e));
        }

    }

}